package cuit.cx.selfview;

import cuit.cx.activity.R;
import cuit.cx.activity.R.styleable;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.graphics.Rect;
import android.util.AttributeSet;
import android.widget.ImageView;

public class ImageViewAddBorder extends ImageView{

	private int colorInt = Color.BLACK;
	private float sizeInt = 1;
	
	public ImageViewAddBorder(Context context) {
		super(context);
	}
	public ImageViewAddBorder(Context context, AttributeSet attrs, int defStyle) {  
		super(context, attrs, defStyle);  
	}  
	public ImageViewAddBorder(Context context, AttributeSet attrs) {  
		super(context, attrs);  
            
			TypedArray ta = context.obtainStyledAttributes(attrs,R.styleable.ImageViewAddBorder);
			colorInt = ta.getColor(R.styleable.ImageViewAddBorder_ivBorderColor, Color.BLACK);
			sizeInt = ta.getDimension(R.styleable.ImageViewAddBorder_ivBorderSize, 2);
			ta.recycle();
		
		
	}  
	
     public void setColour(int color){  

        colorInt = color;  

     }  


     public void setBorderWidth(int width){  

        sizeInt = width;  
    }  

	
	@Override
	 protected void onDraw(Canvas canvas) {
		
		 super.onDraw(canvas);
		 Rect rec = canvas.getClipBounds();
		 rec.bottom--;
		 rec.right--;
		 Paint paint = new Paint();
		 paint.setColor(colorInt);
		 paint.setStyle(Paint.Style.STROKE);
		 paint.setStrokeWidth(sizeInt);
		 canvas.drawRect(rec, paint);
		 
	 }




}
